package brands

import (
	"api/internal/respons"
	"context"
	"device_srv/deviceclient"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

// @Summary 品牌信息展示
// @Description 查询所有品牌信息
// @Tags 列表展示
// @Accept json
// @Produce json
// @Param data body types.SendSmsReques true "data"
// @Success 200 {object} types.Response
// @Failure 400 {string} types.Response
// @Failure 500 {string} types.Response
// @Router /brands/brandsList [get]
type BrandsListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewBrandsListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BrandsListLogic {
	return &BrandsListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// BrandsList 品牌信息列表展示
func (l *BrandsListLogic) BrandsList(req *types.BrandsListRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	list, err := l.svcCtx.DeviceRpc.BrandsList(l.ctx, &deviceclient.BrandsListRequest{
		BrandName: req.BrandName,
		Page:      req.Page,
		PageSize:  req.PageSize,
	})
	if err != nil {
		return respons.Error(400, "查询失败", err.Error()), err
	}
	return respons.Success(list), nil
}
